package com.feihao.zhou.countDownLatch;

import java.util.concurrent.CountDownLatch;

/**
 * 方法 解释
 public CountDownLatch(int count) 参数传递线程数，表示等待线程数量
 public void await() 让线程等待
 public void countDown() 当前线程执行完毕
 CountDownLatch类 :
 使用场景： 让某一条线程等待其他线程执行完毕之后再执行

 */
public class MyCountDownDemo {
    public static void main(String[] args) {
        //创建CountDownLatch对象，底层定义计数器，3个线程。每Down一个，就少等待一个。
        CountDownLatch countDownLatch = new CountDownLatch(3);

        new Thread(new MotherThread(countDownLatch)).start();
        new Thread(new ChildThread1(countDownLatch)).start();
        new Thread(new ChildThread2(countDownLatch)).start();
        new Thread(new ChildThread3(countDownLatch)).start();
    }
}
